<template>
  <div class="head-nav">
    <div class="logo flex-center">
      <i class="iconfont iconweibiaoti-"></i>
      <span class="word">{{title}}钱包后台</span>
    </div>
    <div class="btn-group flex-right">
      <div class="user" v-if="$store.state.userInfo.uid">
        <span>UID : {{$store.state.userInfo.uid}}</span>
      </div>
      <div class="user flex-center">
        <i class="iconfont iconyonghu"></i>
        <span>{{$store.state.userInfo.username}}</span>
      </div>
      <div class="out flex-center" @click="loginOut()">
        <i class="iconfont icontuichu"></i>
        <span>退出</span>
      </div>
    </div>
  </div>
</template>

<script>
import { getUserInfo } from "../views/common.service";
export default {
  name: "HeaderNav",
  mounted() {
    this.getUserInfo();
  },
  computed: {
    title() {
      return process.env.VUE_APP_TITLE || "";
    }
  },
  methods: {
    loginOut() {
      this.$store.commit("clearInfo");
      this.$router.push("/");
    },
    async getUserInfo() {
      const res = await getUserInfo();
      if (res && res.code === 0) {
        this.$store.commit("updateUserInfo", res.data);
      }
      // console.log(res);
    }
  }
};
</script>

<style lang="scss" scoped>
.head-nav {
  height: 100%;
  background-color: $admin_bg_head;
  .logo {
    float: left;
    height: 100%;
    width: 200px;
    i {
      font-size: 30px;
      float: left;
      color: #59bfc6;
    }
    .word {
      color: #93cbfb;
      font-size: 20px;
      font-weight: bold;
    }
  }
  .btn-group {
    float: right;
    height: 100%;
    padding-right: 10px;
    > div {
      height: 20px;
      line-height: 20px;
      margin: 0 10px;
      span {
        font-size: 14px;
        margin-left: 8px;
      }
    }
    .user {
      span {
        color: #fff;
      }
      i {
        margin-top: 1px;
        font-size: 22px;
        color: #1e6190;
      }
    }
    .out {
      font-size: 14px;
      color: #ff6c00;
      cursor: pointer;
      i {
        margin-top: 1px;
      }
    }
  }
}
</style>

